<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>永嘉前线指挥中心</title>
    <link rel="stylesheet" href="./static/assets/css/iconfont.css">
    <link rel="stylesheet" href="./static\font\iconfont.css">
    <link rel="stylesheet" href="./static/css/common.css">
    <link rel="stylesheet" href="./static/css/index.css">
    <link rel="stylesheet" href="./static/css/Xiang.css">
    <link rel="stylesheet" href="./static/css/Login.css">
    <script src="./static/assets/js/jquery-3.3.1.min.js"></script>
    <script src="./static/js/xiang.js"></script>
    <script src="./static/js/vue.js"></script>
</head>

<body id="investmentRisk">
    <div id="container">
        <header class="header-bg">

            <div class="clock">2020-00-00 00:00:00</div>
            <div class="blackClass">
                <div class="left"></div>
                <div class="right"></div>
            </div>
        </header>
        <div>
            <div class="auto loginbox">
                <div class="loginTitle center bold">用户登录</div>
                <div class="center loginboxli relative col80 auto">
                    <div class="iconfont iconaui-icon-my absolute" style="font-size: 30px;"></div>
                    <input type="text" class="col100 auto" placeholder="用户名" v-model="form.username">
                </div>
                <div class="center loginboxli relative col80 auto">
                    <div class="iconfont iconpassword absolute" style="font-size: 30px;"></div>
                    <input type="password" class="col100 auto" placeholder="密码" v-model="form.password">
                </div>
                <div class="center loginboxli relative col80 auto">
                    <div class="iconfont iconsafety absolute" style="font-size: 22px;left: 13px;"></div>
                    <input type="text" class="col100 auto" placeholder="验证码" v-model="form.verification">
                    <img :src="captcha" class="absolute captcha" @click="LoginVerification">
                </div>
                <div class="center">
                    <div class="loginButton" @click="Login">登录</div>
                </div>

            </div>
        </div>
        <footer class="footer-bg"></footer>
    </div>
    <script type="text/javascript">
        var loginpath = "http://yjtf.wztusheng.com/api/";
        getAlock();
        new Vue({
            el: "#container",
            data: {
                captcha: null,//验证码图片
                form: {//登录信息
                    username: null,
                    password: null,
                    verification: null,
                    cookie: null,
                },
            },
            mounted: function () {
                this.LoginVerification();
                this.Cookie();
            },
            methods: {
                Cookie() {//设置cookie
                    var cookie = document.cookie;
                    var cookieArray = cookie.split("; ");
                    var cookieObj = {};
                    for (let i = 0; i < cookieArray.length; i++) {
                        var arr = cookie.split("=");
                        cookieObj[arr[0]] = arr[1];
                    }
                    this.form.cookie = cookieObj.userName;
                    if (cookieObj.userName) {
                        this.Login();
                    }
                },
                LoginVerification() {//验证码图片
                    this.captcha = loginpath + 'captcha?v=' + Date.parse( new Date());
                },
                Login() {//登录接口
                    var that = this;
                    $.ajax({
                        url: loginpath + 'user/login',
                        type: 'POST',
                        data: {
                            account: this.form.username,
                            password: this.form.password,
                            captcha: this.form.verification,
                            yj_token: this.form.cookie,
                        },
                        contentType: 'application/x-www-form-urlencoded',
                        success: function (res) {
                            if (res.code == 200) {
                                console.log(res)
                                document.cookie = 'userName=' + res.data.yunxin_token;
                                document.cookie = 'accid=' + res.data.yunxin_accid;
                                window.location.href="index.html"
                            } else {
                                that.LoginVerification();
                                that.form.verification = null;
                            }
                        },

                    })
                },
            }
        });

    </script>





</body>

</html>